load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "scheduler",
    srcs = [
        "balancer.go",
        "collector.go",
        "interface.go",
        "nodes.go",
        "scheduler.go",
        "scheduler_manager.go",
        "slots.go",
        "state_transform.go",
        "testutil.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/disttask/framework/scheduler",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/disttask/framework/handle",
        "//pkg/disttask/framework/proto",
        "//pkg/disttask/framework/scheduler/mock",
        "//pkg/disttask/framework/storage",
        "//pkg/domain/infosync",
        "//pkg/kv",
        "//pkg/lightning/log",
        "//pkg/metrics",
        "//pkg/sessionctx",
        "//pkg/util",
        "//pkg/util/backoff",
        "//pkg/util/cpu",
        "//pkg/util/disttask",
        "//pkg/util/intest",
        "//pkg/util/logutil",
        "//pkg/util/syncutil",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_log//:log",
        "@com_github_prometheus_client_golang//prometheus",
        "@org_uber_go_mock//gomock",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "scheduler_test",
    timeout = "short",
    srcs = [
        "balancer_test.go",
        "main_test.go",
        "nodes_test.go",
        "scheduler_manager_nokit_test.go",
        "scheduler_manager_test.go",
        "scheduler_nokit_test.go",
        "scheduler_test.go",
        "slots_test.go",
    ],
    embed = [":scheduler"],
    flaky = True,
    race = "off",
    shard_count = 34,
    deps = [
        "//pkg/config",
        "//pkg/disttask/framework/mock",
        "//pkg/disttask/framework/proto",
        "//pkg/disttask/framework/scheduler/mock",
        "//pkg/disttask/framework/storage",
        "//pkg/disttask/framework/testutil",
        "//pkg/domain/infosync",
        "//pkg/kv",
        "//pkg/sessionctx",
        "//pkg/testkit",
        "//pkg/testkit/testfailpoint",
        "//pkg/testkit/testsetup",
        "//pkg/util/cpu",
        "//pkg/util/disttask",
        "//pkg/util/logutil",
        "//pkg/util/sqlexec",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//util",
        "@org_uber_go_goleak//:goleak",
        "@org_uber_go_mock//gomock",
    ],
)
